<?php

require_once("../model/user.php");

$obj_user = new User();

$username = $_POST['username'];

$address  = $_POST['address'];

$data = $obj_user->search_user_by_address_and_name($username, $address);

// $length = sizeof($data);

// var_dump($data);
if(sizeof($data) == 0)
{
    echo "<center><i>Không tìm thấy dữ liệu!</i><center>";
    exit();
} 

echo "<table class=\"table table-striped\">";
    echo "<thead>";
        echo "<th>Mã user</th>";
        echo "<th>Tên</th>";
        echo "<th>Quyền</th>";
        echo "<th>Địa chỉ</th>";
        echo "<th>Giới tính</th>";
        echo "<th colspan='2'>Tác vụ</th>";
    echo "</thead>";

    echo "<tbody>";
            foreach($data as $key=>$value)
            {
                echo "<tr>";
                    $user_id = $value['user_id'];
                    echo "<td>".$value['user_id']."</td>";
                    echo "<td>".$value['username']."</td>";
                    echo "<td>".$value['user_role']."</td>";
                    echo "<td>".$value['user_address']."</td>";
                    echo "<td>".$value['user_sex']."</td>";
                    echo "<td><a href=\"edit_user.php?user_id=$user_id\">Edit</a></td>";
                    echo "<td><a class='del-user' href='?user_id={$user_id}&command=delete'>Delete</a></td>";
                echo "</tr>";
            }
    echo "</tbody>";
echo "</table>";

